package com.yn.yzq.service.impl;

import com.yn.yzq.dao.LoginServiceMapper;
import com.yn.yzq.entity.User;
import com.yn.yzq.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    @Qualifier("loginServiceMapper")
    private LoginServiceMapper loginServiceMapper;

    @Override
    public Map<String, Object> loginValid(Map userInfo) {
        Map<String, Object> getUserInfo = loginServiceMapper.loginValid(userInfo);
        if (getUserInfo != null && !getUserInfo.equals("")) {
            return getUserInfo;
        } else {
            return null;
        }
    }

    //写if else代码的时候
    // 可以先想想失败的
    // 然后才是成功
    // 也就是报错在前成功在后
    // 失败是成功之母

    @Override
    public boolean registerUser(Map<String, Object> user) {
        int i = loginServiceMapper.registerUser(user);
        if (i != 1) {
            return false;
        } else {
            return true;
        }
    }
}
